package com.jswlw.service.biz.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jswlw.dao.biz.BookInfoMapper;
import com.jswlw.entity.biz.BookInfo;
import com.jswlw.service.biz.BookInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookInfoServiceImpl implements BookInfoService {
    @Autowired
    BookInfoMapper mapper;

    @Override
    public void add(BookInfo bookInfo) {
        mapper.insertSelective(bookInfo);
    }

    @Override
    public void update(BookInfo bookInfo) {
        mapper.updateByPrimaryKeySelective(bookInfo);
    }

    @Override
    public void delete(Integer id) {
        mapper.deleteByPrimaryKey(id);
    }

    @Override
    public BookInfo find4Id(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public List<BookInfo> queryList(BookInfo filter) {
        return mapper.queryList(filter);
    }

    @Override
    public Page<BookInfo> queryPage(BookInfo bookInfo, Integer offset, Integer limit) {
        PageHelper.startPage(offset, limit);
        return (Page<BookInfo>) mapper.queryList(bookInfo);
    }
}
